Stepping into the New Macromedia Flash MX 2004 Component Structure
Table of Contents
Search and Destroy
Table 2 shows you many typical commands you might have used in v1 components along with the equivalent v2 component code that you'll need to use instead in your v2 component-based projects. The table is not so much intended as a complete reference but to give you a feel for how things have changed. You can search your existing code for any uses of the items in the left column or search for the component instance names you used instead. (Note, however, that component instances you referenced dynamically will not turn up when searching for explicit instance names.)
Table 2. Mapping v1 Component Syntax to v2 Component Equivalents
| v1 Component Syntax | v2 Component Equivalent |
|---|---|
myButton.setLabel("new label") |
myButton.label="new label" |
curLabel=myButton.getLabel() |
curLabel=myButton.label |
myComponent.setEnabled(true) |
myComponent.enabled=true |
curEnabled=myComponent.getEnabled() |
curEnabled=myComponent.enabled |
myList.setSelectedIndex(newIndex) |
myList.selectedIndex=newIndex |
curIndex=myList.getSelectedIndex() |
curIndex=myList.selectedIndex |
myList.addItem("label", "data"); |
unchanged |
myList.getItemAt( index ) |
unchanged |
myList.removeAll() |
unchanged |
myComponent.setEditable(true) |
myComponent.editable=true |
myButton.setClickHandler( "myFunction") |
myButton.addEventListener ("click", myFunction) |
myComponent.setStyleProperty( "theProp", "value") |
myComponent.setStyle("theProp", "value") |
In the end, it's hard to refrain from praising the new components. However, while all the new cool features are great for your next project, the reality is, you'll likely have to update old projects. Knowing the key differences between v1 and v2 components, you should now be able to asses, plan, and execute the migration to the v2 component architecture—provided it's appropriate for your application.